package org.nvm.test;

public class LemmaUtil {

	public static double variance(int[] values) {
		float total = 0;
		float avg = average(values);
		for(int v : values) {
			total += (v - avg) * (v - avg);
		}
		
		return Math.sqrt(total);
	}
	
	public static float sum(int[] values) {
		float r = 0;
		for(int i : values) {
			r += i;
		}
		return r;
	}
	
	public static float average(int[] values) {
		if(values == null || values.length < 1) {
			return 0;
		}
		return sum(values) / values.length;
	}
}
